generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kernel): add support for concurrency with ants pool (#44)
- Loading branch information
1 parent
c1bf0db
commit 41531e0
Showing
32 changed files
with
701 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package tv | ||
|
||
import ( | ||
"github.com/snivilised/lorax/boost" | ||
"github.com/snivilised/traverse/core" | ||
) | ||
|
||
type ( | ||
// TraverseInput represents the type of inputs accepted by the worker pool | ||
TraverseInput struct { | ||
// Node represents the file system entity (file or folder) for which | ||
// a job will execute. | ||
Node *core.Node | ||
|
||
// Handler is the client defined callback function that should be | ||
// invoked for all eligible Nodes. | ||
Handler core.Client | ||
} | ||
|
||
// TraverseJobStream represents the core channel type of the worker pool's | ||
// input stream. The client owns this channel and is responsible for | ||
// closing it when done or invoking Conclude directly on the pool (See | ||
// boost for more details). | ||
TraverseJobStream = boost.JobStream[TraverseInput] | ||
|
||
// TraverseJobStreamR worker pool's read stream, pool reads from this channel. | ||
TraverseJobStreamR = boost.JobStreamR[TraverseInput] | ||
|
||
// TraverseJobStreamW worker pool's write stream, client writes to this channel. | ||
TraverseJobStreamW = boost.JobStreamW[TraverseInput] | ||
|
||
// TraverseOutput represents the output of a single job executed by the pool. | ||
TraverseOutput struct { | ||
// Node represents the file system entity (file or folder) from | ||
// which this output was generated via the client defined handler. | ||
Node *core.Node | ||
|
||
// Error error result of client's handler. | ||
Error error | ||
|
||
// Data is a custom field reserved for the client | ||
Data any | ||
} | ||
|
||
// TraverseOutputStream represents the core channel type of the worker pool's | ||
// output stream. The pool owns this stream and will be closed only when | ||
// safe to do so, which will be anytime after navigation is complete. | ||
// The channel is only closed when there are no remaining outstanding jobs | ||
// and all workers are idle. | ||
TraverseOutputStream = boost.JobOutputStream[TraverseOutput] | ||
|
||
// TraverseOutputStreamR worker pool's output stream read by the client. | ||
TraverseOutputStreamR = boost.JobOutputStreamR[TraverseOutput] | ||
|
||
// TraverseOutputStreamW worker pool's output stream written to by the pool. | ||
TraverseOutputStreamW = boost.JobOutputStreamW[TraverseOutput] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
package core | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type Navigator interface { | ||
Navigate() (TraverseResult, error) | ||
Navigate(ctx context.Context) (TraverseResult, error) | ||
} | ||
|
||
type NavigatorFunc func() (TraverseResult, error) | ||
type Navigate func() (TraverseResult, error) | ||
|
||
func (fn NavigatorFunc) Navigate() (TraverseResult, error) { | ||
func (fn Navigate) Navigate() (TraverseResult, error) { | ||
return fn() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.